﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ClienteConsulta.aspx.cs" Inherits="NewTierra.Pages.Cliente.ClienteConsulta" %>

<!DOCTYPE html>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <link rel="shortcut icon" href="../../images/Icones/favicon.ico" type="image/x-icon" />

    <link href="../../Styles/jquery_notification.css" rel="stylesheet" />

    <link href="../../Styles/jquery-ui.css" rel="stylesheet" />    
    <script type="text/javascript" src="../../Scripts/jquery-1.11.0.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-ui-1.10.0.js"></script>

    <script type="text/javascript" src="../../Scripts/jquery_notification_v.1.js"></script>

    <link href="~/Styles/EstiloGeral.css" rel="stylesheet" type="text/css" />

    <style type="text/css">
        #Cliente
        {
            width: 1330px;
            height: 660px;
            margin-top: 25px;
            margin-left: 5px;
            margin-right: 5px;
        }

        #ClienteForm
        {
            width: 624px;
            height: 580px;
            float: left;
        }

            #ClienteForm .FiltrosCliente
            {
                border: 1px solid #999;
                margin-bottom: 5px;
                padding: 10px;
                background-color: #EEE;
                height: auto;
                background: #FAFAFA;
                color: #666;
            }

            #ClienteForm .CliCadastro
            {
                height: 449px;
                float: left;
                width: 606px;
            }

        #GridContatoMarkup
        {
            height: 554px;
            float: left;
            width: 647px;
            margin-left: 30px;
        }

        #SetCliente
        {
            height: auto;
            width: 621px;
            border-radius: 10px;
        }

        #SetContato
        {
            border-radius: 10px;
            height: auto;
        }

        .GridContatos
        {
            margin-top: 5px;
            height: 234px;
            width: 627px;
        }

        .ClienteFormularioCrud
        {
            height: 440px;
            padding: 5px;
            display: inline;
            float: left;
            position: relative;
            border: 1px solid #E6E6E6;
            background: #FAFAFA;
            color: #666;
        }

            .ClienteFormularioCrud .CliCadastroEsq
            {
                width: 335px;
                float: left;
                height: 388px;
            }

            .ClienteFormularioCrud .CliCadastroDir
            {
                width: 250px;
                float: left;
                height: 389px;
            }

            .ClienteFormularioCrud .CliCadastroBotoes
            {
                width: 584px;
                height: 37px;
                float: left;
            }

        .Contatos
        {
            height: 542px;
            width: 632px;
        }
    </style>
</head>
<body>

    <script type="text/javascript">

        jQuery(function ($) {
            $.datepicker.regional['pt-BR'] = {
                closeText: 'Fechar',
                prevText: '&#x3c;Anterior',
                nextText: 'Pr&oacute;ximo&#x3e;',
                currentText: 'Hoje',
                monthNames: ['Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho',
             'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
                monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
             'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
                dayNames: ['Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sabado'],
                dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
                weekHeader: 'Sm',
                dateFormat: 'dd/mm/yy',
                firstDay: 0,
                isRTL: false,
                showMonthAfterYear: false,
                yearSuffix: ''
            };
            $.datepicker.setDefaults($.datepicker.regional['pt-BR']);
        });

        $(function () {
            $("#txtSinceDataCliente").datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 1
            });

            $("#accordion").accordion();

        });

        function CallServerCliente() {
            document.getElementById('<%= btnFiltroNomeClientes.ClientID %>').click();
        }

        function OpenInfos(siteInfos) {
            var home = siteInfos;
            javascript: window.open(home);
        }

        function AbrirPopUp(url, title, w, h) {
            var left = (screen.width / 2) - (w / 2);
            var top = (screen.height / 2) - (h / 2);
            return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left + '');
        }

        function ShowIcon() {
            var e = document.getElementById("processing");
            e.style.visibility = (e.style.visibility == 'visible') ? 'hidden' : 'visible';
        }

        function showAutoCloseMessage(MsgsExc) {
            showNotification({
                message: MsgsExc,
                autoClose: true,
                type: "success",
                duration: 5
            });
        }

    </script>

    <form id="formulario" runat="server">

        <asp:ScriptManager ID="ScriptManagerCliente" runat="server">
        </asp:ScriptManager>

        <div class="bgHeader">

            <div class="bgHeader_into">

                <asp:ImageButton ID="ImgVoltarMenu" runat="server" ImageUrl="~/images/Icones/iconeMenu2.png" OnClick="VoltarMenu" ToolTip="Menu" />

            </div>

            <div class="bgHeader_into">

                <asp:Label ID="lblSupplierHeader" runat="server" Text="Cliente" CssClass="titulo" />

            </div>

        </div>

        <div id="Cliente">

            <div id="ClienteForm">

                <fieldset id="SetCliente">
                    <legend>
                        <h3 style="margin-bottom: 0px">Cliente
                            <asp:Label ID="lblClienteNomeTituloTXT" runat="server" Text="" /></h3>
                    </legend>

                    <div class="FiltrosCliente radius">

                        <div class="FiltrosSupplier_into_search">
                            <asp:TextBox ID="txtClientes" runat="server" placeholder="Informe o nome do Cliente." Width="340px" MaxLength="50"></asp:TextBox>
                            <img id="processing" alt="load" style="visibility: hidden" src="../../images/ajax-loader.gif" />
                        </div>

                        <div class="FiltrosSupplier_into_btn">

                            <input id="btnShowVerClientes" class="btnGeralAzul" onclick="AbrirPopUp('VerTodosClientes.aspx', 'Clientes', '750', '500')" style="height: 30px;" type="button" value="List" />
                            <asp:Button ID="btnFiltroNomeClientes" Style="display: none" runat="server" OnClick="CarregarClienteNome" />
                        </div>

                        <asp:AutoCompleteExtender
                            ID="AutoCompleteExtenderClientes"
                            runat="server"
                            CompletionInterval="100"
                            DelimiterCharacters=""
                            EnableCaching="False"
                            Enabled="True"
                            MinimumPrefixLength="1"
                            OnClientItemSelected="CallServerCliente"
                            OnClientPopulated="ShowIcon"
                            OnClientPopulating="ShowIcon"
                            ServiceMethod="SearchCliente"
                            TargetControlID="txtClientes" ServicePath="">
                        </asp:AutoCompleteExtender>
                    </div>

                    <div class="ClienteFormularioCrud radius">

                        <div class="CliCadastro">
                            <div class="CliCadastroEsq">

                                <asp:TextBox ID="txtCodCliente" runat="server" Style="display: none;" />

                                <p class="paragrafo">
                                    <asp:Label ID="lblNomeClienteTXT" runat="server" Text="Nome:"></asp:Label><br />
                                    <asp:TextBox ID="txtNomeCliente" runat="server" Width="300px" MaxLength="50" />
                                    <asp:RequiredFieldValidator
                                        ID="RqFieldNomeCliente"
                                        runat="server"
                                        ControlToValidate="txtNomeCliente"
                                        ErrorMessage="*"
                                        ValidationGroup="Salvar"
                                        ToolTip="Campo requerido."></asp:RequiredFieldValidator>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblEnderecoClienteTXT" runat="server" Text="Endereço:"></asp:Label><br />
                                    <asp:TextBox ID="txtEnderecoCliente" runat="server" TextMode="MultiLine" Width="300px" Height="44px" MaxLength="200" />
                                    <%--<asp:RequiredFieldValidator
                                        ID="RqFieldEndereco"
                                        runat="server"
                                        ControlToValidate="txtEnderecoCliente"
                                        ErrorMessage="*"
                                        ValidationGroup="Salvar"
                                        ToolTip="Campo requerido."></asp:RequiredFieldValidator>--%>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblHttpTXT" runat="server" Text="Site:"></asp:Label><br />
                                    <asp:TextBox ID="txtHttp" runat="server" Width="300px" MaxLength="100" />
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblCepClienteTXT" runat="server" Text="Cep:"></asp:Label><br />
                                    <asp:TextBox ID="txtCepCliente" runat="server" Width="150px" MaxLength="12" />
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblTelefoneClienteTXT" runat="server" Text="Telefone:"></asp:Label><br />
                                    <asp:TextBox ID="txtTelefoneCliente" runat="server" Width="150px" MaxLength="20" />
                                    <%--<asp:RequiredFieldValidator
                                        ID="RqFieldTelefone"
                                        runat="server"
                                        ControlToValidate="txtTelefoneCliente"
                                        ErrorMessage="*"
                                        ValidationGroup="Salvar"
                                        ToolTip="Campo requerido."></asp:RequiredFieldValidator>--%>
                                    <%--<asp:RegularExpressionValidator
                                            ID="ReTelefone"
                                            runat="server"
                                            ErrorMessage="*"
                                            ControlToValidate="txtTelefoneCliente"
                                            ToolTip="Telefone inválido"
                                            ValidationGroup="Salvar"
                                            ValidationExpression="[0-9+]{3} [0-9]{2} [0-9]{4}-[0-9]{4}" />--%>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblFaxClienteTXT" runat="server" Text="Fax:"></asp:Label><br />
                                    <asp:TextBox ID="txtFaxCliente" runat="server" Width="150px" MaxLength="15" />
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblEmailClienteTXT" runat="server" Text="Email:"></asp:Label><br />
                                    <%--<asp:TextBox ID="txtEmailClienteMailto" runat="server" Width="200px" MaxLength="50" onClick="javascript:window.location = 'mailto:' + this.value; return false;" Visible="false" />--%>
                                    <asp:TextBox ID="txtEmailCliente" runat="server" Width="200px" MaxLength="50" />
                                    <asp:RegularExpressionValidator ID="ValidatorEmail" runat="server" ControlToValidate="txtEmailCliente" ErrorMessage="*" ToolTip="Email inválido." ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="Salvar"></asp:RegularExpressionValidator>
                                </p>

                            </div>

                            <div class="CliCadastroDir">

                                <p class="paragrafo">
                                    <asp:Label ID="lblSinceCliente" runat="server" Text="Since:"></asp:Label><br />
                                    <asp:TextBox ID="txtSinceDataCliente" runat="server" Width="100px" MaxLength="10" />
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblRepresentanteXlienteTXT" runat="server" Text="Representante:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlRepresentante" runat="server" Width="270px">
                                    </asp:DropDownList>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblCentroCustoClienteTXT" runat="server" Text="Centro Custo:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlCentroCusto" runat="server">
                                    </asp:DropDownList>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblMercadoClienteTXT" runat="server" Text="Mercado:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlMercado" runat="server">
                                    </asp:DropDownList>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblBaseTarifariaTXT" runat="server" Text="BaseTarifaria:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlBaseTarifaria" runat="server">
                                    </asp:DropDownList>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblPaisClienteTXT" runat="server" Text="País:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlPais" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPais_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </p>

                                <p class="paragrafo">
                                    <asp:Label ID="lblCidadeClienteTXT" runat="server" Text="Cidade:"></asp:Label><br />
                                    <asp:DropDownList ID="ddlCidade" runat="server">
                                    </asp:DropDownList>
                                </p>

                            </div>

                            <div class="CliCadastroBotoes">
                                <asp:Button ID="btnNovoCliente" runat="server" Text="Salvar" CssClass="btnGeralAzul" OnClick="CadastrarCliente" ValidationGroup="Salvar" />
                                <asp:Button ID="btnAtualizarCliente" runat="server" CssClass="btnGeralAzul" OnClick="AtualizarCliente" Text="Atualizar" ValidationGroup="Salvar" />
                                <asp:Button ID="btnExcluirCliente" runat="server" CssClass="btnGeralAzul" OnClick="ExcluirCliente" Text="Excluir" OnClientClick="return confirm('Excluindo esse cliente, todos os contatos do mesmo também serão excluídos. Confirma?');" />
                                <asp:Button ID="btnLimparCliente" runat="server" CssClass="btnGeralAzul" OnClick="LimparCliente" Text="Limpar" />
                            </div>
                            <asp:Label ID="lblMsgCadCliente" runat="server" Font-Bold="True"></asp:Label>
                        </div>

                    </div>

                </fieldset>

            </div>

            <div id="GridContatoMarkup">

                <fieldset id="SetContato">
                    <legend>
                        <h3>Contatos</h3>
                    </legend>

                    <div class="Contatos">

                        <asp:Panel ID="PanelContatos" runat="server" Visible="false" Height="533px" Width="638px">

                            <asp:Button ID="btnShowContatos" runat="server" CssClass="btnGeralAzul" Text="Contato" OnClientClick="AbrirPopUp('AddContato_Cliente.aspx?Tipo=novo', 'Contatos', '940', '430')" />
                            <%--<input id="btnShowContatos" class="btnGeralAzul" value="Contato" onclick="AbrirPopUp('AddContato_Cliente.aspx?Tipo=novo', 'Contatos', '940', '430')" type="button" />--%>

                            <asp:Button ID="btnShowMarkup" runat="server" CssClass="btnGeralAzul" Text="Markup" OnClientClick="AbrirPopUp('ClienteMarkup.aspx?Tipo=novo', 'Markup', '1060', '360')" />
                            <%--<input id="btnShowMarkup" class="btnGeralAzul" value="Markup" onclick="AbrirPopUp('ClienteMarkup.aspx?Tipo=novo', 'Markup', '1060', '360')" type="button" />--%>


                            <br />
                            <br />
                            <br />


                            <div id="accordion">

                                <h3>Contatos</h3>
                                <div style="overflow-x:hidden; overflow-y: auto;">
                                    <asp:ImageButton ID="btnAtualizarGridContatos" ToolTip="Atualizar Contatos" runat="server" ImageUrl="~/images/Icones/refresh-icon.png" OnClick="AtualizaGridsContatos" />

                                    <div class="GridContatos">

                                        <asp:GridView ID="GridContatosCliente" runat="server" AllowPaging="True"
                                            AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr"
                                            AlternatingRowStyle-CssClass="alt" EmptyDataText="Não existe contato para esse cliente."
                                            Height="16px" PageSize="8">
                                            <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>

                                            <Columns>
                                                <asp:BoundField DataField="Contato_id" HeaderText="ID" ReadOnly="True"
                                                    SortExpression="Contato_id" InsertVisible="False">
                                                    <FooterStyle CssClass="invisible" />
                                                    <HeaderStyle CssClass="invisible" />
                                                    <ItemStyle CssClass="invisible" />
                                                </asp:BoundField>

                                                <asp:BoundField DataField="Contato_nome" HeaderText="Nome"
                                                    SortExpression="Contato_nome" />

                                                <asp:BoundField DataField="Contato_position" HeaderText="Cargo"
                                                    SortExpression="Contato_position" />

                                                <asp:BoundField DataField="Contato_telefone" HeaderText="Telefone"
                                                    SortExpression="Contato_telefone" />

                                                <asp:BoundField DataField="Contato_fax" HeaderText="Fax"
                                                    SortExpression="Contato_fax" />

                                                <asp:BoundField DataField="Contato_email" HeaderText="Email"
                                                    SortExpression="Contato_email" />

                                                <asp:TemplateField HeaderText="">
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="imgBtnEditarContato"
                                                            runat="server" ToolTip="Editar Contato"
                                                            CommandArgument='<%# Eval("Contato_id") %>'
                                                            OnCommand="EditarContato" ImageUrl="~/images/Icones/edit.png" />
                                                    </ItemTemplate>
                                                    <HeaderStyle Wrap="False" />
                                                    <ItemStyle Wrap="False" />
                                                </asp:TemplateField>

                                                <asp:TemplateField HeaderText="">
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="imgBtnExcluirContato"
                                                            runat="server" ToolTip="Excluir Contato"
                                                            CommandArgument='<%# Eval("Contato_id") %>'
                                                            OnCommand="ExcluirContato" ImageUrl="~/images/Icones/delete.png" />
                                                    </ItemTemplate>
                                                    <HeaderStyle Wrap="False" />
                                                    <ItemStyle Wrap="False" />
                                                </asp:TemplateField>

                                            </Columns>

                                            <PagerStyle CssClass="pgr"></PagerStyle>

                                        </asp:GridView>

                                    </div>
                                </div>

                                <h3>Markup</h3>
                                <div style="overflow-x:hidden; overflow-y: auto;">
                                    <div class="GridContatos">

                                        <asp:ImageButton ID="btnAtualizarGridMarkup" ToolTip="Atualizar Markup" runat="server" ImageUrl="~/images/Icones/refresh-icon.png" OnClick="AtualizaGridsMarkup" />

                                        <asp:GridView ID="GridMarkup" runat="server" AllowPaging="True"
                                            AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr"
                                            AlternatingRowStyle-CssClass="alt" EmptyDataText="Não existe markup para esse cliente."
                                            Height="16px" PageSize="5" Width="581px">
                                            <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
                                            <Columns>

                                                <asp:BoundField DataField="Markup_dataInicial" HeaderText="Inicial" SortExpression="Markup_dataInicial" DataFormatString="{0:dd/MM/yyyy}" />
                                                <asp:BoundField DataField="Markup_dataFinal" HeaderText="Final" SortExpression="Markup_dataFinal" DataFormatString="{0:dd/MM/yyyy}" />
                                                <asp:BoundField DataField="Markup_hotel" HeaderText="Hotel" SortExpression="Markup_hotel" />
                                                <asp:BoundField DataField="Markup_descontoHotel" HeaderText="Desc Hotel" SortExpression="Markup_descontoHotel" />
                                                <asp:BoundField DataField="Markup_servico" HeaderText="Serviço" SortExpression="Markup_servico" />
                                                <asp:BoundField DataField="Markup_descontoServico" HeaderText="Desc Serviço" SortExpression="Markup_descontoServico" />

                                                <asp:TemplateField HeaderText="">
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="imgBtnEditarMarkup"
                                                            runat="server" ToolTip="Editar Markup"
                                                            CommandArgument='<%# Eval("Markup_id") %>'
                                                            OnCommand="EditarMarkup" ImageUrl="~/images/Icones/edit.png" />
                                                    </ItemTemplate>
                                                    <HeaderStyle Wrap="False" />
                                                    <ItemStyle Wrap="False" />
                                                </asp:TemplateField>

                                                <asp:TemplateField HeaderText="">
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="imgBtnExcluirMarkup"
                                                            runat="server" ToolTip="Excluir Markup"
                                                            CommandArgument='<%# Eval("Markup_id") %>'
                                                            OnCommand="ExcluirMarkup" ImageUrl="~/images/Icones/delete.png" />
                                                    </ItemTemplate>
                                                    <HeaderStyle Wrap="False" />
                                                    <ItemStyle Wrap="False" />
                                                </asp:TemplateField>

                                            </Columns>

                                            <PagerStyle CssClass="pgr"></PagerStyle>
                                        </asp:GridView>

                                    </div>
                                </div>
                            </div>

                        </asp:Panel>
                    </div>

                </fieldset>

            </div>

        </div>

    </form>
</body>
</html>
